package com.world.rickcloudendpoint.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @description: 订阅主题
 * @author: jlsong
 * @date: 2021/12/12 21:12:51
 * @version: 1.0
 */
public enum Topic {
    Aaa(1, "Aaa", "Aaa信号主题"),
    Bbb(2,"Bbb", "Bbb信号主题"),
    ;


    private int code;
    private String name;
    private String desc;

    Topic(int code, String name, String desc) {
        this.code = code;
        this.name = name;
        this.desc = desc;
    }

    @Override
    @JsonValue
    public String toString() {
        return String.valueOf(name);
    }

    @JsonCreator
    public static Topic fromName(String name) {
        for (Topic b : Topic.values()) {
            if (String.valueOf(b.name).equals(name)) {
                return b;
            }
        }
        return null;
    }
}
